package day13;

import java.util.*;

public class homework {

}

class A3{
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("abc");
        list.add("123");
        list.add("java");
        list.add("mysql");
        list.add("别跑啊");
        for(int i=0;i<list.size();i++){
            for(int j=list.get(i).length();j<4;j++){
                list.set(i,"0"+list.get(i));
            }
        }
        System.out.println(list);
    }
}

class B3{
    public static void main(String[] args) {
        List<User> list = new ArrayList<>();
        list.add(new User(1,"abc",26));
        list.add(new User(2,"def",45));
        list.add(new User(3,"ghi",56));
        list.add(new User(4,"jkl",37));
        list.add(new User(5,"mno",58));
        list.add(new User(6,"pqrs",49));
        list.add(new User(7,"tuv",50));
        list.add(new User(8,"qwe",51));
        list.add(new User(9,"zxc",30));
        list.add(new User(10,"mnb",63));
        Iterator<User> it = list.iterator();
        while(it.hasNext()){
            User user = it.next();
            System.out.print("id:"+user.id+"\t");
            System.out.print("name:"+user.name+"\t");
            System.out.println("age:"+user.age+"\t");
        }
    }
}

class User{
    int id;
    String name;
    int age;
    public User(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }
}

class C3{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        List<String> list1 = new ArrayList<>();
        List<String> list2 = new ArrayList<>();
        List<String> list3 = new ArrayList<>();
        System.out.println("请输入list1的元素");
        while(true){
            String str = sc.next();
            if(str.equals("exit")){
                break;
            }
            list1.add(str);
        }
        System.out.println("添加成功");
        System.out.println("请输入list1的元素");
        while(true){
            String str = sc.next();
            if(str.equals("exit")){
                break;
            }
            list2.add(str);
        }
        for (String item : list1) {
            if (!list3.contains(item)) { // 检查是否已存在
                list3.add(item);
            }
        }
        for (String item : list2) {
            if (!list3.contains(item)) {
                list3.add(item);
            }
        }
        System.out.println(list3);
    }
}

class A4{
    public static void main(String[] args) {
        int[] arr = new int[10];
        int i=0;
        Scanner sc=new Scanner(System.in);
        while(true){
            System.out.println("请输入一个元素");
            arr[i] = sc.nextInt();
            if(arr[i]==-9999){
                System.exit(0);
            }
            else {
                i++;
                if(i+1==arr.length){
                    arr=addition(arr);
                }
            }
        }
    }

    static int[] addition(int[] o){
        int NewLength=o.length;
        o= Arrays.copyOf(o,NewLength);
        System.out.println("扩容成功");
        return o;
    }
}

class B4{
    public static void main(String[] args) {
        List<Student> list = new ArrayList<>();
        Random r=new Random();
        for(int i=0;i<40;i++) {
            int id = r.nextInt(40) + 180201;
            String name = (char) (r.nextInt(26) + 97) + "";
            int score = r.nextInt(51) + 50;
            list.add(new Student(id,name,score));
        }
        Collections.sort(list,(o1,o2)->{
            int n= o2.score-o1.score;
            if(n==0){
                n=o1.id-o2.id;
            }
            return n;
        });
        for(Student e:list){
            System.out.println(e.id+" "+e.name+" "+e.score);
        }
    }
}

class Student{
    int id;
    String name;
    int score;
    public Student(int id, String name, int score) {
        this.id = id;
        this.name = name;
        this.score = score;
    }
}